package com.tuantuan.common.base.result;

import com.tuantuan.common.base.common.IServerErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author wangqinmin
 * @date 2018-11-08
 * @description: 仰天大笑出门去，我辈岂是蓬蒿人
 */
@Slf4j
public class ApiController {

    protected final Logger logger = LoggerFactory.getLogger(getClass());


    /**
     * 请求成功
     *
     * @param data 数据内容
     * @param <T>  对象泛型
     * @return ignore
     */
    protected <T> Responses<T> success(T data) {
        return Responses.ok(data);
    }

    /**
     * 请求失败
     *
     * @param msg 提示内容
     * @return ignore
     */
    protected <T> Responses<T> failed(String msg) {
        return Responses.failed(msg);
    }

    /**
     * 请求失败
     *
     * @param errorCode 请求错误码
     * @return ignore
     */
    protected <T> Responses<T> failed(IServerErrorCode errorCode, String errorMsg) {
        return Responses.failed(errorCode, errorMsg);
    }

}
